// pages/add/add.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    city:"重庆",
    userInfoList:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var _this = this
    wx.getStorage({
      key: 'cityName',
      success: function (res) {
        _this.setData({
          city: res.data
        })
      }
    })
    this.personalInformation()
  },
  onShow:function(options) {
    this.personalInformation()
  },
  personalInformation:function(){
    wx.showLoading({
      title: '加载中',
    })
    var that=this
    wx.request({
      url: 'https://miniapp.odeman.com/summercamp/select_connection.php', 
      data: {
        userid:wx.getStorageSync('userid')
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        wx.hideLoading()
        var data = res.data
        if(data.status=="success"){
          for (var k in data.list) {
            data.list[k].isShow = false
          }
          that.setData({
            userInfoList:data.list
          })
        }
      }
    })

  },
  // 展开
  donwShow:function(e) {
    var _this = this
    var index = e.currentTarget.dataset.index
    var list = _this.data.userInfoList
      list[index].isShow = !list[index].isShow

    this.setData({
      userInfoList:_this.data.userInfoList
    })
  }
  
})